<?php

class IndexAction extends CommAction
{
    /**
     * 首页
     */
    public function index(){
        $fid = session::get('fid');
        if($fid){
            $ss['fid'] = $fid;
            $ss['uid'] = M('wxuser')->where(array('openid'=>session::get('openid')))->getField('id');
            if($fid != $ss['uid']){
                //判断是否已经是团员
                $exist = M('members')->where($ss)->find();
                if(!$exist){
                    //存储团员信息
                    $map['fid'] = $fid;
                    $map['uid'] = $ss['uid'];
                    $map['createtime'] = time();
                    M('members')->add($map);
                    //存储用户获取积分的途径
                    $pp['userid'] = $fid;
                    $pp['type'] = 3;
                    $pp['points'] = M('market_settings')->where(array('id'=>1))->getField('points1');
                    $pp['create_time'] = time();
                    M('wxuser_get_points')->add($pp);
                }
            }
        }
        $programNname = explode('/',$_SERVER['REDIRECT_URL']);
        $prefix = 'http://'.$_SERVER['HTTP_HOST'].'/'.$programNname[1].'/upload/homepage/';
        $info = M('home_page')->select();
        $this->assign('info',$info);
        $this->assign('prefix',$prefix);
        $this->display();

    }

    //模块1
    public function part1(){
        $this->display();
    }
    
    //模块1--子模块
    public function part1son(){
        $this->display();
    }

    public function test(){
        $this->display();
    }
    public function testAjax(){
        if(IS_AJAX){
            $base64 = I('post.content');
            $img = base64_decode($base64);
            $a = file_put_contents('./test.jpg', $img);
            $this->ajaxReturn(array('val'=>$img));
        }
    }
}
?>